//
//  JGThirdPartyGamepad.h
//  JGInputDriver
//
//  Created by jagger.tu on 2025/3/26.
//

#import <JGInputDriver/JGInputDriver.h>

NS_ASSUME_NONNULL_BEGIN

#ifndef __JG_GAME_PAD_BUTTON_VALUE__
#define __JG_GAME_PAD_BUTTON_VALUE__

#define JG_GP_A_FLAG     0x1000 // F0 00
#define JG_GP_B_FLAG     0x2000
#define JG_GP_X_FLAG     0x4000
#define JG_GP_Y_FLAG     0x8000

#define JG_GP_UP_FLAG    0x0001 // 00 0F
#define JG_GP_DOWN_FLAG  0x0002
#define JG_GP_LEFT_FLAG  0x0004
#define JG_GP_RIGHT_FLAG 0x0008

#define JG_GP_LB_FLAG    0x0100 // 0F 00
#define JG_GP_RB_FLAG    0x0200

#define JG_GP_PLAY_FLAG  0x0010 // 00 F0
#define JG_GP_BACK_FLAG  0x0020

#define JG_GP_LS_CLK_FLAG  0x0040 // 00 F0
#define JG_GP_RS_CLK_FLAG  0x0080

#define JG_GP_SPECIAL_FLAG 0x0400 // 0F 00

#define JG_GP_LT_FLAG     100001 //
#define JG_GP_RT_FLAG     100002

#define JG_GP_EMULATING_SELECT     0x1 // 00 0F
#define JG_GP_EMULATING_SPECIAL    0x2

#endif

/// 第三方手柄使用
@interface JGThirdPartyGamepad : JGGamepad

/// 手柄按键的状态
/// - Parameters:
///   - flag: 见宏定义 `__JG_GAME_PAD_BUTTON_VALUE__ `
///   - isPressed: YES 表示按下, up 表示抬起
- (void)updateBtnWithFlag:(uint16_t)flag isPressed:(BOOL)isPressed;

/// 左边扳机的状态变化
/// - Parameters:
///   - x: 横坐标,取值范围是 [-1,1]
///   - y: 纵坐标,取值范围是 [-1,1]
- (void)updateLeftStickX:(double)x Y:(double)y;
/// 右边扳机的状态变化
/// - Parameters:
///   - x: 横坐标,取值范围是 [-1,1]
///   - y: 纵坐标,取值范围是 [-1,1]
- (void)updateRightStickX:(double)x Y:(double)y;

/// 左右触发键状态变化
/// - Parameters:
///   - left: 左边的变化,取值范围是 [0,1]
///   - right: 右边的变化,取值范围是 [0,1]
- (void)updateTriggerWithLeft:(double)left right:(double)right;
/// 左触发键状态变化
/// - Parameters:
///   - left: 左边的变化,取值范围是 [0,1]
- (void)updateTriggerWithLeft:(double)left;
/// 右触发键状态变化
/// - Parameters:
///   - right: 右边的变化,取值范围是 [0,1]
- (void)updateTriggerWithRight:(double)right;

/// 将手柄状态的改变,立即同步到云端
- (void)commit;

@end

NS_ASSUME_NONNULL_END
